<?php

class People_ImageController extends Base_Controller_Action
{
    
    public function indexAction()
    {
        //street list
        $dbTable = new Table_Street();
        $this->view->entries = $dbTable->view(array(), 'sid ASC');
    }
    
    public function streetAction()
    {
        $street = new Model_Street();
        try {
            $street->read($this->_getParam('sid'));
        }
        catch (Base_Exception $e) {
            return $this->_helper->ErrorPage(404);
        }
        
        $this->view->street = $street;
        
        //village list
        $dbTableVillage = new Table_Village();
        $whereArray1['`sid` = ?'] = (int) $this->_getParam('sid');
        $this->view->villages = $dbTableVillage->view($whereArray1, 'vid ASC');
        
        //village list
        $dbTableGroup = new Table_Group();
        $whereArray2['`vid` LIKE ?'] = substr($street->sid, 0, 2).'%';
        $this->view->groups = $dbTableGroup->view($whereArray2, 'vid ASC');
    }
    
    public function villageAction()
    {
        $village = new Model_Village();
        try {
            $village->readBy('vid', $this->_getParam('vid'));
        }
        catch (Base_Exception $e) {
            return $this->_helper->ErrorPage(404);
        }
        
        $this->view->village = $village;
    }
}